package com.ls.cameraxtest;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.navigation.fragment.NavHostFragment;

public class FirstFragment extends Fragment {

    @Override
    public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState ) {
        return inflater.inflate(R.layout.fragment_first, container, false);
    }

    @Override
    public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        view.findViewById(R.id.button_camera_1).setOnClickListener(view12 -> {
            if(getActivity() instanceof MainActivity){
                ((MainActivity)getActivity()).goCamera(1);
            }
//                NavHostFragment.findNavController(FirstFragment.this) .navigate(R.id.action_FirstFragment_to_Camera1Fragment);
        });
        view.findViewById(R.id.button_camera_2).setOnClickListener(view1 -> {
            if(getActivity() instanceof MainActivity){
                ((MainActivity)getActivity()).goCamera(2);
            }
//                NavHostFragment.findNavController(FirstFragment.this) .navigate(R.id.action_FirstFragment_to_Camera2Fragment);
        });
    }

    @Override
    public void onResume() {
        super.onResume();
        ((MainActivity)getActivity()).setTitle("选个相机拍照啊");
    }
}